acpi: Makefile should better tolerate interrupts
authorBoris Ostrovsky <boris.ostrovsky@oracle.com>
Fri, 23 Sep 2016 16:23:47 +0000 (18:23 +0200)
committerJan Beulich <jbeulich@suse.com>
Fri, 23 Sep 2016 16:23:47 +0000 (18:23 +0200)
Intermediate stages of building a target should be made with
temporary files that are copied to final target in the end.

Signed-off-by: Boris Ostrovsky <boris.ostrovsky@oracle.com>
Acked-by: Jan Beulich <jbeulich@suse.com>
tools/firmware/hvmloader/acpi/Makefile

index d3e882ac694987a02ba9783764f3dc1bb926c8ec..45de14a5635ab149e5c1cb0a9facd2d3f72a8d33 100644 (file)
@@ -22,6 +22,9 @@ OBJS  = $(patsubst %.c,%.o,$(C_SRC))
 
 CFLAGS += $(CFLAGS_xeninclude)
 
+# Suffix for temporary files.
+TMP_SUFFIX     = tmp
+
 vpath iasl $(PATH)
 all: acpi.a
 
@@ -34,18 +37,21 @@ mk_dsdt: mk_dsdt.c
        $(HOSTCC) $(HOSTCFLAGS) $(CFLAGS_xeninclude) -o $@ mk_dsdt.c
 
 dsdt_anycpu_qemu_xen.asl: dsdt.asl mk_dsdt
-       awk 'NR > 1 {print s} {s=$$0}' $< > $@
-       ./mk_dsdt --debug=$(debug) --dm-version qemu-xen >> $@
+       awk 'NR > 1 {print s} {s=$$0}' $< > $@.$(TMP_SUFFIX)
+       ./mk_dsdt --debug=$(debug) --dm-version qemu-xen >> $@.$(TMP_SUFFIX)
+       mv -f $@.$(TMP_SUFFIX) $@
 
 # NB. awk invocation is a portable alternative to 'head -n -1'
 dsdt_%cpu.asl: dsdt.asl mk_dsdt
-       awk 'NR > 1 {print s} {s=$$0}' $< > $@
-       ./mk_dsdt --debug=$(debug) --maxcpu $*  >> $@
+       awk 'NR > 1 {print s} {s=$$0}' $< > $@.$(TMP_SUFFIX)
+       ./mk_dsdt --debug=$(debug) --maxcpu $*  >> $@.$(TMP_SUFFIX)
+       mv -f $@.$(TMP_SUFFIX) $@
 
 $(filter dsdt_%.c,$(C_SRC)): %.c: iasl %.asl
        iasl -vs -p $* -tc $*.asl
-       sed -e 's/AmlCode/$*/g' $*.hex >$@
-       echo "int $*_len=sizeof($*);" >>$@
+       sed -e 's/AmlCode/$*/g' $*.hex >$@.$(TMP_SUFFIX)
+       echo "int $*_len=sizeof($*);" >>$@.$(TMP_SUFFIX)
+       mv -f $@.$(TMP_SUFFIX) $@
        rm -f $*.aml $*.hex
 
 iasl:
@@ -63,7 +69,7 @@ acpi.a: $(OBJS)
 
 clean:
        rm -rf *.a *.o $(IASL_VER) $(IASL_VER).tar.gz $(DEPS)
-       rm -rf ssdt_*.h dsdt*.c *~ *.aml *.hex mk_dsdt dsdt_*.asl
+       rm -rf ssdt_*.h dsdt*.c *~ *.aml *.hex mk_dsdt dsdt_*.asl *.$(TMP_SUFFIX)
 
 distclean: clean